/*
 * Created on 2005-4-13
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.efesco.stat.dynamicQuery;

import org.dom4j.io.*;
import org.dom4j.Element;
import java.io.File;
import org.dom4j.Document;
import java.net.MalformedURLException;
import org.dom4j.DocumentException;

public class XMLReadAndWrite {
	
	public XMLReadAndWrite(){
		
	}
	public static Document read(String fileName) throws DocumentException {
      SAXReader reader = new SAXReader();
      Document document;
      //System.out.println(fileName);
      File f = new File(fileName);
      try{
      	document = reader.read(f);
      	//reader.re
      	return document;
      }catch(DocumentException e){
      	System.out.println("222222");
      }
      return null;
   }
	
	public static Element getRootElement(Document doc){
      return doc.getRootElement(); 
   } 
	
	public static String getXMLattribute(Element el,String attname){
		if (el.attribute(attname)!=null){
			return el.attribute(attname).getText();
		}else{
			return "";
		}
	}
}
